/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.luedinski.objects;

import java.util.ArrayList;

/**
 *
 * @author lueder
 */
public class Schedule {

    private ArrayList<ScheduledRoute> routes = new ArrayList<ScheduledRoute>();

    public void addTrain(Route route, Time departure) {
        ScheduledRoute sRoute = new ScheduledRoute(route, departure);
        routes.add(sRoute);
    }

    public ArrayList<ScheduledRoute> getTrains(Station origin, Station destination, Time t) {
        ArrayList<ScheduledRoute> trains = new ArrayList<ScheduledRoute>();
        for (int i = 0; i < routes.size(); i++) {
            if (routes.get(i).containsEdge(origin, destination) && routes.get(i).getDeparture().compareTo(t) >= 0) {
                trains.add(routes.get(i));
            }
        }
        return trains;
    }

    public void printSchedule() {
        for (int i = 0; i < routes.size(); i++) {
            System.out.println(routes.get(i).toString());
        }
    }
}
